<template>
  <!-- 显示的标签要根据用户传过来的数据决定 -->
  <div class="tab-control">
    <div v-for="(item, index) in titles" :key="index" class="tab-title" :class="{active:index===num}"  @click="titleClick(index)">
      <span >{{item}}</span>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
        num:0
    };
  },
  props: {
    titles: {
      type: Array,
      //   默认返回一个空数组
      default() {
        return [];
      },
    },
  },
  created() {
    console.log(this.titles);
  },
  methods:{
      titleClick(index){
         this.num=index
         this.$emit('guigeClick',index)
      }
  }
};
</script>

<style scoped>
.tab-control {
  display: flex;
  height: 44px;
  justify-content: space-between;
  background: white;
  }
.tab-title {
  flex: 1;
  text-align: center;
  font-size: 15px;
}
.active{
    color: #FF8198;
}
.active span{
    border-bottom: 3px solid #FF8198;
    padding: 3px;
}
</style>